#!coding=utf-8
from django.contrib import admin
from django.forms import ModelForm
from api.menu import sendmenu
from django.core.exceptions import ValidationError
from models import *
from team4us.options.admin import T4ModelAdmin,StackedInline
from mptt.admin import MPTTModelAdmin
class WMenuAdmin(MPTTModelAdmin):
    """
    """
    list_display = ('name','wtype','value',)
    list_filter = ('wtype',)
    actions=['update_menu']
    def update_menu(self, request, queryset):
        result,code=sendmenu()
        if result!=True:
            self.message_user(request, u'%s' %code)
        else:
            self.message_user(request,u'菜单更新成功！')
    update_menu.short_description = "更新菜单到微信"

admin.site.register(WMenu,WMenuAdmin)

class UserAdmin(T4ModelAdmin):
    list_display = ('openid','nickname',)

admin.site.register(User,UserAdmin)